import { Map } from "immutable";
import { CHANGE_LOGINSTATE, CHANGE_USERINFO } from "../type";
const reducer = (
    //  adminInfo: JSON.parse(window.localStorage.getItem("adminInfo")) || {}, // 存储用户信息
    // loginState: window.localStorage.getItem("loginState") === "true", // 判断当前是否登录
  state = Map({ userinfo: JSON.parse(window.localStorage.getItem('userinfo'))||{}, loginstate: window.localStorage.getItem('loginstate')==='true'}),
  { type, payload }
) => {
  switch (type) {
    case CHANGE_USERINFO:
      window.localStorage.setItem("userinfo", JSON.stringify(payload));
      return state.set("userinfo", payload);
    case CHANGE_LOGINSTATE:
      window.localStorage.setItem("loginstate", payload);
      return state.set("loginstate", payload);
    default:
      return state;
  }
};
export default reducer;
